/**
 * 学习目标：类组件中，创建state
 */
import React from 'react';
import ReactDOM from 'react-dom';

class App extends React.Component {
  // 1.state属性声明状态,键名代表变量名
  // 💥state的值，一定要是对象类型
  state = {
    msg: 'hello React',
    list: [1, 2, 3],
  };

  render() {
    console.log('this  ----->  ', this);
    // 2. 获取this.state.xxx
    return (
      <div>
        {this.state.msg}
        <ul>
          {this.state.list.map((item) => {
            return <li key={item}>{item}</li>;
          })}
        </ul>
      </div>
    );
  }
}

ReactDOM.render(<App></App>, document.getElementById('root'));
